var path = require("path");

var express = require("express");

var essay = require("../models/essay");

var cates = require("../config/cates");
var settings = require("../config/settings");

var router = express.Router();
router.get("/", function(req, res, next) {
  essay
    .find({})
    .sort("-createTime")
    .populate("user")
    .exec(function(err, essays) {
      res.render("index", {
        essays: essays,
        cates: cates,
        config: settings,
        title: settings["siteName"],
        currentCate: ""
      });
    });
});
module.exports = router;
